<template>
  <div id="app2">
    <el-container>
      <el-aside width="200px">
        <el-row class="tac">
          <el-col :span="12" id="left">
            <el-menu default-active="2" class="el-menu-vertical-demo">
              <el-menu-item index="3">
                <span slot="title">欢迎光临:&nbsp;{{ username }}</span>
              </el-menu-item>
              <el-menu-item index="1">
                <i class="el-icon-menu"></i>
                <span slot="title">首页</span>
              </el-menu-item>
              <el-submenu index="2">
                <template slot="title">
                  <div>
                    <i class="el-icon-document"></i>
                    <span class="span">页面管理</span>
                  </div>
                </template>
                <el-menu-item-group>
                  <el-menu-item index="1-1" id="el" @click="myshop1"
                    >我的商铺</el-menu-item
                  >
                  <el-menu-item index="1-2" id="el" @click="myshop2"
                    >添加商铺</el-menu-item
                  >
                  <el-menu-item index="1-3" id="el" @click="myshop3"
                    >商铺管理</el-menu-item
                  >
                  <el-menu-item index="1-4" id="el" @click="myshop4"
                    >食品管理</el-menu-item
                  >
                  <el-menu-item index="1-5" id="el" @click="myshop5"
                    >订单管理</el-menu-item
                  >
                </el-menu-item-group>
              </el-submenu>
            </el-menu>
          </el-col>
        </el-row>
      </el-aside>
      <el-main>
        <el-breadcrumb separator="/">
          <el-breadcrumb-item :to="{ path: '/index' }">首页</el-breadcrumb-item>
          <el-breadcrumb-item>
            <a href="#">业务管理</a>
          </el-breadcrumb-item>
          <el-breadcrumb-item>食品管理</el-breadcrumb-item>
          <el-dropdown>
            <span class="el-dropdown-link"> 个人中心</span>
            <i class="el-icon-arrow-down el-icon--right"></i>
            <el-dropdown-menu slot="dropdown">
              <v-nav></v-nav>
            </el-dropdown-menu>
          </el-dropdown>
        </el-breadcrumb>
        <el-button type="success" @click="tianjia">添加</el-button>
        <div v-show="tianjia1" class="tianjia1">
          <p style="width: 100%; text-align: center; font-size: 16px;">
            添加菜单
          </p>
          <div style="margin-top: 20px;">
            <span>商品名称:</span>
            <el-input
              v-model="input1"
              placeholder="请输入内容"
              style="width: 400px; margin-left: 20px;"
            ></el-input>
          </div>
          <div style="margin-top: 20px;">
            <span>商品介绍:</span>
            <el-input
              v-model="input2"
              placeholder="请输入内容"
              style="width: 400px; margin-left: 20px;"
            ></el-input>
          </div>
          <div style="margin-top: 20px;">
            <span>商品价格:</span>
            <el-input
              v-model="input3"
              placeholder="请输入内容"
              style="width: 400px; margin-left: 20px;"
            ></el-input>
          </div>
          <div
            style="margin-top: 20px; display: flex; justify-content: center;"
          >
            <el-button type="primary" @click="queding">确定</el-button>
            <el-button
              type="primary"
              style="background-color: lightgray; border: 0;"
              >取消</el-button
            >
          </div>
        </div>
        <div class="dingdan">
          <tr>
            <td>食品名称</td>
            <td>食品介绍</td>
            <td>食品价格</td>
            <td>操作</td>
          </tr>
          <tr v-for="item in list" :key="item._id">
            <td>{{ item.goodsname }}</td>
            <td>{{ item.goodsintroduction }}</td>
            <td>{{ item.goodsprice }}</td>
            <td @click="shanchu(item._id)">删除</td>
          </tr>
          <p v-if="this.list.length == 0" class="p1">暂无数据</p>
        </div>
      </el-main>
    </el-container>
  </div>
</template>

<script>
<<<<<<< HEAD
import nav from  "../../components/nav.vue"
	import a from "../../model/goodsModel"
	export default {
		components: {
			'v-nav':nav
		},
		data() {
			return {
				list: [],
				tianjia1: false,
				input1: "",
				input2: "",
				input3: "",
				username: "",
			}
		},
		methods: {
			tianjia() {
				if(this.tianjia1 == true) {
					this.tianjia1 = false
				} else {
					this.tianjia1 = true
				}
			},
			async queding() {
				let goodsname = this.input1
				let goodsintroduction = this.input2
				let goodsprice = this.input3
				let gprice = 1
				let data = await a.add({goodsname , goodsintroduction , goodsprice , gprice})
				
				let {
					data: data2
				} = await a.query()
				this.list = data2.data
				this.input1 = ""
				this.input2 = ""
				this.input3 = ""
				this.tianjia1 = false
				console.log(data2)
			},
			quxiao() {
				
				this.tianjia1 = false
			},
			async shanchu(goodsname) {
				console.log(goodsname)
				let {
					data
				} = await a.query({
					goodsname
				})
				console.log(data)
			},
			myshop1() {
				this.$router.push("/shops/myshop");
			},
			myshop2() {
				this.$router.push("/shops/add");
			},
			myshop3() {
				this.$router.push("/shops/shop");
			},
			myshop4() {
				this.$router.push("/shops/food");
			},
			myshop5() {
				this.$router.push("/shops/order");
			},
			handleRemove(file) {
				console.log(file);
			},
			handlePictureCardPreview(file) {
				this.dialogImageUrl = file.url;
				this.dialogVisible = true;
			},
			handleDownload(file) {
				console.log(file);
			}
		},
		async created() {
			let {
				data
			} = await a.query()
			this.list = data.data
			// dialogImageUrl: '',
			// 	dialogVisible: false,
			// 	disabled: false,
			// 	input: '',
			// 	username: "",
			// 	console.log(11);
			let info = window.localStorage.getItem("info");
			console.log(info);
			this.username = info;
		}
	}
	</script>
=======
import nav from "../../components/nav.vue";
import a from "../../model/goodsModel";
export default {
  components: {
    "v-nav": nav
  },
  data() {
    return {
      list: [],
      tianjia1: false,
      input1: "",
      input2: "",
      input3: "",
      username: ""
    };
  },
  methods: {
    tianjia() {
      if (this.tianjia1 == true) {
        this.tianjia1 = false;
      } else {
        this.tianjia1 = true;
      }
    },
    async queding() {
      let goodsname = this.input1;
      let goodsintroduction = this.input2;
      let goodsprice = this.input3;
      let gprice = 1;
      let data = await a.add({
        goodsname,
        goodsintroduction,
        goodsprice,
        gprice
      });

      let { data: data2 } = await a.query();
      this.list = data2.data;
      this.input1 = "";
      this.input2 = "";
      this.input3 = "";
      this.tianjia1 = false;
    },
    quxiao() {
      this.tianjia1 = false;
    },
    async shanchu(goodsname) {
      console.log(goodsname);
      let { data: data2 } = await a.shanchu(goodsname);
      console.log(data2);
      let { data } = await a.query(goodsname);
      console.log(data);
      this.list = data.data;
    },
    myshop1() {
      this.$router.push("/shops/myshop");
    },
    myshop2() {
      this.$router.push("/shops/add");
    },
    myshop3() {
      this.$router.push("/shops/shop");
    },
    myshop4() {
      this.$router.push("/shops/food");
    },
    myshop5() {
      this.$router.push("/shops/order");
    },
    handleRemove(file) {
      console.log(file);
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },
    handleDownload(file) {
      console.log(file);
    }
  },
  async created() {
    let { data } = await a.query();
    this.list = data.data;
    // dialogImageUrl: '',
    // 	dialogVisible: false,
    // 	disabled: false,
    // 	input: '',
    // 	username: "",
    // 	console.log(11);
    let info = window.localStorage.getItem("info");
    console.log(info);
    this.username = info;
  }
};
</script>
>>>>>>> 4ec8550f4d58e2b9ecb92f69c9f83472b396d829

<style scoped>
.tianjia1 {
  position: fixed;
  left: 0;
  top: 100px;
  right: 0;
  width: 500px;
  margin-left: auto;
  margin-right: auto;
  background-color: red;
  padding: 20px;
}

.el-popover__reference {
  background-color: greenyellow;
}

.el-popover__reference span {
  color: black;
}

.el-button--text {
  background-color: greenyellow;
  padding: 10px 30px;
}

.el-breadcrumb {
  width: 1000px;
}

.p1 {
  line-height: 100px;
  text-align: center;
}

.dingdan {
  width: 1000px;
  margin-top: 20px;
}

.dingdan tr {
  display: inline-block;
  display: flex;
  width: 100%;
}

.dingdan tr td {
  flex: 1;
  line-height: 53px;
  border: 1px solid black;
  padding-left: 10px;
}

.el-input__inner {
  margin-left: 20px;
}

#el {
  color: #fff;
}

.span {
  background-color: rgb(10, 6, 51);
}

.el-menu-item.is-active {
  background-color: rgb(10, 6, 51);
}

.div {
  margin-bottom: 20px;
}

.el-breadcrumb {
  border-bottom: 1px solid gray;
  margin-bottom: 20px;
}

.el-main {
  padding: 0;
  margin-left: 20px;
}

.el-aside {
  overflow: hidden;
}
</style>
